<?php

/**
 * Document form.
 *
 * @package    erp-crm
 * @subpackage form
 * @author     Milwell H. Sia
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class DocumentForm extends BaseDocumentForm
{
  public function configure()
  {
    $this->widgetSchema['owner_iden']->setOption('peer_method','getListListName');
    if($this->isNew()){
      $this->validatorSchema['document_iden'] = new sfValidatorString(array('required' => true));
    }else{
      $this->widgetSchema['owner_iden']->setAttribute('onFocus','this.blur();');
    }
    
    $this->widgetSchema['counter_code'] = 
      new sfWidgetFormPropelChoice(
        array('model' => 'ListCounters', 'add_empty' => false, 'key_method'=>'getCode', )
      );
    $this->validatorSchema['counter_code'] = 
      new sfValidatorPropelChoice(
        array('model' => 'ListCounters', 'column'=>'code',)
      );
    $this->setDefault('counter_code',0);

    $this->widgetSchema->setLabels(
      array(
        'document_date'=>'Date',
        'owner_iden'=>'Document Owner',
        'counter_code'=>'Counter#',
      )
    );
  }
  
  function setOwnerReadOnly(){
    $this->widgetSchema['owner_iden']->setAttribute('onFocus','this.blur();');
  }
  
}
